<template>
	<view class="app-container">
		<cell title="朋友圈">
			<template v-slot:left>
				<image src="../../static/images/circle-1.png" class="icon"></image>
			</template>
		</cell>
		<cell title="短视频">
			<template v-slot:left>
				<image src="../../static/images/video.png" class="icon"></image>
			</template>
		</cell>
		<cell title="扫一扫" @click.native="handleScanner">
			<template v-slot:left>
				<image src="../../static/images/scanner.png" class="icon"></image>
			</template>
		</cell>
		<cell title="找一找" @click.native="goPath('search')">
			<template v-slot:left>
				<image src="../../static/images/search.png" class="icon"></image>
			</template>
		</cell>
		<cell title="新好友" @click.native="goPath('newFriends')">
			<template v-slot:left>
				<image src="../../static/images/add-friend.png" class="icon"></image>
			</template>
			<template v-slot:right>
				<view v-if="applyTotal" style="color: #007AFF;">{{applyTotal}}</view>
			</template>
		</cell>
	</view>
</template>

<script>
	import Cell from '../../components/cell.vue'
	import {getUser} from '../../utils/auth.js'
	export default {
		components:{
			Cell
		},
		data() {
			return {
				user:{},
				applyTotal:0
			}
		},
		onLoad() {
			this.user = getUser()
			this.getApplyList()
		},
		methods: {
			getApplyList() {
				this.$http('/admin/chat/friendApply/getListByUserId/'+this.user.userInfo.userId).then(res =>{
					this.applyTotal = res.data.list.length
				})
			},
			
			goPath(url){
				uni.navigateTo({
					url:`/pages/discovery/${url}`
				})
			},
			handleScanner() {
				uni.scanCode({
				    success: function (res) {
				        console.log('条码类型：' + res.scanType);
				        console.log('条码内容：' + res.result);
						plus.runtime.openURL(res.result);
				    }
				});
			}
		}
	}
</script>

<style>

</style>
